Skip to content

Conversation

@tungol
Copy link
Contributor

@tungol tungol commented Jan 2, 2026

fixes #15207

_socket.pyi constants are ordered based on the CPython documentation, but that doesn't seem to be the case in socket.pyi. I could merge the new if sys.platform != "darwin": blocks into existing if sys.platform != "darwin": blocks there, but I decided not to because the whole file really could use some re-organization in that regard.

If it's amenable, I could apply the same systematic ordering that I did for os.__all__ in #13052 to the blocks in socket.pyi responsible for import statements and __all__.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link

@dlech dlech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. 😄


if sys.platform != "linux":
__all__ += ["AF_LINK"]
if sys.platform != "darwin" and sys.platform != "linux":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if sys.platform != "darwin" and sys.platform != "linux":
if sys.platform != "darwin":

Comment on lines +31 to +37
_?socket.AF_BLUETOOTH
_?socket.BDADDR_ANY
_?socket.BDADDR_LOCAL
_?socket.BTPROTO_HCI
_?socket.BTPROTO_L2CAP
_?socket.BTPROTO_RFCOMM
_?socket.BTPROTO_SCO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably make these entries optional, in case the GitHub runners change and to help with running stubtest locally in different environments.

Suggested change
_?socket.AF_BLUETOOTH
_?socket.BDADDR_ANY
_?socket.BDADDR_LOCAL
_?socket.BTPROTO_HCI
_?socket.BTPROTO_L2CAP
_?socket.BTPROTO_RFCOMM
_?socket.BTPROTO_SCO
(_?socket\.AF_BLUETOOTH)?
(_?socket\.BDADDR_ANY)?
(_?socket\.BDADDR_LOCAL)?
(_?socket\.BTPROTO_HCI)?
(_?socket\.BTPROTO_L2CAP)?
(_?socket\.BTPROTO_RFCOMM)?
(_?socket\.BTPROTO_SCO)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bluetooth socket constants missing on Linux

3 participants